package com.itheima.mapper;

import com.itheima.pojo.Brand;
import org.apache.ibatis.annotations.*;


public interface BrandMapper {

    @Select("select * from tb_brand where id = #{id}")
    //配置结果集
    @Results(id = "brand", value = {
            @Result(column = "brand_name", property = "brandName"),
            @Result(column = "company_name", property = "companyName")
    })
    public Brand findById(Integer id);

    @Insert("insert into tb_brand (id, brand_name, company_name, ordered, description, status) " +
            "values (null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    public int save(Brand brand);

    @Update("update tb_brand set " +
            "brand_name=#{brandName}," +
            "company_name=#{companyName}," +
            "ordered=#{ordered}," +
            "description=#{description}," +
            "status=#{status} " +
            "where id =#{id}")
    public int update(Brand brand);

    @Delete("delete from tb_brand where id = #{id}")
    public int delete(Integer id);
}
